import 'package:demo/view/blue/flutter_blue_plus.dart';
import 'package:demo/view/html_map/html_map.dart';
import 'package:demo/view/interactive_viewer_2/interactive_viewer_2_page.dart';
import 'package:demo/view/pie_chart/pie_chart.dart';
import 'package:demo/view/excel/export_excel.dart';
import 'package:demo/view/contain_list/list_page.dart';
import 'package:demo/view/contain_list/list_page_1.dart';
import 'package:demo/view/contain_list/list_table.dart';
import 'package:demo/view/pop_menu/popup_menu_button.dart';
import 'package:demo/view/map/svg_map.dart';
import 'package:demo/view/contain_list/second_list.dart';
import 'package:demo/view/selectable_text/selectable_text_page.dart';
import 'package:demo/view/zoom_drag/zoom_drag_example.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

class AppRouter {
  static const String home = '/';
  static const String secondListView = '/second-list-view';
  static const String secondList = '/second-list';
  static const String listPage1 = '/list-page-1';
  static const String listTable = '/list-table';
  static const String popupMenu = '/popup-menu';
  static const String exportExcel = '/export-excel';
  static const String svgMap = '/svg-map';
  static const String pieChart = '/pie-chart';
  static const String htmlMap = '/html-map';
  static const String bluetooth = '/bluetooth';
  static const String interactiveViewer = '/interactive-viewer';
  static const String selectableText = '/selectable-text';
  static const String zoomDrag = '/zoom_drag';

  static final GoRouter router = GoRouter(
    initialLocation: home,
    routes: [
      GoRoute(
        path: home,
        name: 'home',
        builder: (BuildContext context, GoRouterState state) {
          return const MyHomePage();
        },
      ),
      GoRoute(
        path: secondListView,
        name: 'secondListView',
        builder: (BuildContext context, GoRouterState state) {
          return const SecondListViewPage();
        },
      ),
      GoRoute(
        path: secondList,
        name: 'secondList',
        builder: (BuildContext context, GoRouterState state) {
          return const SecondListPage();
        },
      ),
      GoRoute(
        path: listPage1,
        name: 'listPage1',
        builder: (BuildContext context, GoRouterState state) {
          return const ListPage1();
        },
      ),
      GoRoute(
        path: listTable,
        name: 'listTable',
        builder: (BuildContext context, GoRouterState state) {
          return const ListTable();
        },
      ),
      GoRoute(
        path: popupMenu,
        name: 'popupMenu',
        builder: (BuildContext context, GoRouterState state) {
          return const PopupMenuButtonPage();
        },
      ),
      GoRoute(
        path: exportExcel,
        name: 'exportExcel',
        builder: (BuildContext context, GoRouterState state) {
          return ExportExcelPage();
        },
      ),
      GoRoute(
        path: svgMap,
        name: 'svgMap',
        builder: (BuildContext context, GoRouterState state) {
          return const MapWidget();
        },
      ),
      GoRoute(
        path: pieChart,
        name: 'pieChart',
        builder: (BuildContext context, GoRouterState state) {
          return const PieChartWidget();
        },
      ),
      GoRoute(
        path: htmlMap,
        name: 'htmlMap',
        builder: (BuildContext context, GoRouterState state) {
          return const ChinaMapPage();
        },
      ),
      GoRoute(
        path: bluetooth,
        name: 'bluetooth',
        builder: (BuildContext context, GoRouterState state) {
          return const BluetoothPage();
        },
      ),
      GoRoute(
        path: interactiveViewer,
        name: 'interactiveViewer',
        builder: (BuildContext context, GoRouterState state) {
          return const InteractiveViewer2Page();
        },
      ),
      GoRoute(
        path: selectableText,
        name: 'selectableText',
        builder: (BuildContext context, GoRouterState state) {
          return const SelectableTextPage();
        },
      ),
      GoRoute(
        path: zoomDrag,
        name: zoomDrag,
        builder: (BuildContext context, GoRouterState state) {
          return const ZoomDragExample();
        },
      ),
    ],
  );
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('ListView'),
      ),
      body: ListView(
        children: <Widget>[
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.secondListView);
            },
            child: const Text('自定义二级列表'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.secondList);
            },
            child: const Text('系统二级列表'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.listPage1);
            },
            child: const Text('系统二级列表'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.listTable);
            },
            child: const Text('ListTable'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.popupMenu);
            },
            child: const Text('PopupMenuButtonPage'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.exportExcel);
            },
            child: const Text('ExportExcelPage'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.svgMap);
            },
            child: const Text('svg_map'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.pieChart);
            },
            child: const Text('PieChartWidget'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.htmlMap);
            },
            child: const Text('html_map'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.bluetooth);
            },
            child: const Text('blue'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.interactiveViewer);
            },
            child: const Text('InteractiveViewer2Page'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.selectableText);
            },
            child: const Text('SelectableTextPage'),
          ),
          ElevatedButton(
            onPressed: () {
              context.go(AppRouter.zoomDrag);
            },
            child: const Text('zoomDrag'),
          ),
        ],
      ),
    );
  }
}